package com.rivulet.dawn.web.controller.archive;

import com.rivulet.dawn.api.request.AllDeleteRequest;
import com.rivulet.dawn.api.request.archive.EventRecordQueryRequest;
import com.rivulet.dawn.api.request.archive.EventRecordSaveRequest;
import com.rivulet.dawn.api.request.archive.EventRecordUpdateRequest;
import com.rivulet.dawn.api.response.archive.EventRecordDetailResponse;
import com.rivulet.dawn.api.response.archive.EventRecordSearchResponse;
import com.rivulet.dawn.api.tools.Page;
import com.rivulet.dawn.api.tools.ResultFul;
import com.rivulet.dawn.service.service.archive.EventRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author: xjc
 * @date: 2022/8/16 14:36
 * @Desc: 事件档案管理
 **/
@Api(value = "事件档案管理",tags = "事件档案管理")
@RestController
@RequestMapping("archive/event/")
public class EventRecordController {
    private final EventRecordService eventRecordService;

    public EventRecordController(EventRecordService eventRecordService) {
        this.eventRecordService = eventRecordService;
    }

    @ApiOperation(value = "事件新增")
    @PostMapping("create")
    public ResultFul<Integer> create(@RequestBody EventRecordSaveRequest request){
        return ResultFul.OK(eventRecordService.create(request));
    }

    @ApiOperation(value = "事件删除")
    @PostMapping("delete")
    public ResultFul<Object> delete(@RequestBody AllDeleteRequest request){
        eventRecordService.delete(request);
        return ResultFul.OK();
    }

    @ApiOperation(value = "事件修改")
    @PostMapping("update")
    public ResultFul<Integer> update(@RequestBody EventRecordUpdateRequest request){
        return ResultFul.OK(eventRecordService.update(request));
    }

    @ApiOperation(value = "事件查询")
    @PostMapping("search")
    public ResultFul<Page<EventRecordSearchResponse>> search(@RequestBody EventRecordQueryRequest request){
        return ResultFul.OK(eventRecordService.search(request));
    }

    @ApiOperation(value = "事件详情")
    @GetMapping("detail")
    public ResultFul<EventRecordDetailResponse> detail(Long id){
        return ResultFul.OK(eventRecordService.detail(id));
    }
}
